<template>
  <div class="ticket-view">
    <!-- 顶部导航栏 -->
    <van-nav-bar
        title="计划详情"
        left-arrow
        @click-left="sy"
        fixed
    />

    <!-- 筛选菜单 -->
    <div class="filter-container">
      <van-dropdown-menu>
        <van-dropdown-item
            title="工单状态"
            v-model="value3"
            :options="option3"
            @change="gdlx"
        />
        <van-dropdown-item
            title="全部"
            :options="option4"
            @change="list"
        />
      </van-dropdown-menu>
    </div>

    <!-- 工单列表 -->
    <div class="ticket-list">
      <div v-for="ticket in data" :key="data.id" class="ticket-item"  @click="jhxq(ticket.id)">
        <div class="ticket-header">
          <div class="ticket-id">编号：{{ ticket.code}}</div>
          <div class="ticket-status">
            <span>{{ticket.planbegintime}}-{{ticket.dispatchtime}}</span>
          </div>
        </div>
        <div class="ticket-content">
            <div class="ticket-id">处理时限:{{ ticket.timelimit}}<span v-if="ticket.timelimit!=null">小时</span></div>
            <div class="ticket-status">
              <span style="font-size: 13px">状态:<span style="font-size: 13px" v-if="ticket.executionstatus==1">启用</span><span style="font-size: 13px" v-if="ticket.executionstatus==2">禁用</span></span>
            </div>

        </div>
      </div>
    </div>


  </div>

</template>

<script>
export default {
  name: "Workorderbjjh",
  data() {
    return {
      value3: 0,
      data: [],
      option3: [
        {text: '启动', value: 1},
        {text: '禁用', value: 2},
      ],
      option4: [
        {text: '全部', value: 1},
      ],
      pid:0,
      names:'',
    }
  },
  created() {
    this.userhq();
    this.list();
  },
  mounted() {
  },
  methods: {

    userhq(){
      const item = localStorage.getItem('aa');

      const aaaa= JSON.parse(item)
      this.names= aaaa['username'];
      let phone= aaaa['phone'];
      this.pid=aaaa['pid']
    },


   jhxq(id) {
     this.$router.push({path: '/workorderbjjhxq', query: {id: id}})
   },

    sy() {
      this.$router.push('/medical')
    },

    gdlx(val) {
      if (this.pid==1){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/listexecutionstatus?type=` + val).then(res => {
          this.data = res.data.data;
          console.log(this.data);
        })
      }
      if (this.pid==2){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/listexecutionstatuss?type=${val}&worker=${this.names}`).then(res => {
          this.data = res.data.data;
          console.log(this.data);
        })
      }
      if (this.pid==3){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/listexecutionstatusss?type=${val}&name=${this.names}`).then(res => {
          this.data = res.data.data;
          console.log(this.data);
        })
      }

    },


    list() {
      if (this.pid==1){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/list`).then(res => {
          if (res.data.code == 1){
            this.data = res.data.data;
            console.log(this.data);
          }
        })
      }
      if (this.pid==2){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/list2?worker=`+this.names).then(res => {
          if (res.data.code == 1){
            this.data = res.data.data;
            console.log(this.data);
          }
        })
      }
      if (this.pid==3){
        this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/listname?name=`+this.names).then(res => {
          if (res.data.code == 1){
            this.data = res.data.data;
            console.log(this.data);
          }
        })
      }

    },


  },

}
</script>

<style scoped>

.task-details {
  padding: 20px;
}

.ticket-view {
  min-height: 100vh;
  background-color: #f7f8fa;
  padding-top: 46px;
  top: 30px;
}

.filter-container {
  position: sticky;
  top: 46px;
  z-index: 10;
}

:deep(.van-dropdown-menu) {
  background-color: #fff;
}

.ticket-list {
  padding: 12px;
}

.ticket-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebedf0;
}

.ticket-id {
  font-size: 14px;
  color: #323233;
}

.ticket-priority {
  font-size: 14px;
  font-weight: 500;
}

.ticket-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-info {
  font-size: 13px;
  color: #646566;
  line-height: 1.5;
}

:deep(.van-button--primary) {
  background-color: #1989fa;
  border-color: #1989fa;
}

:deep(.van-button--success) {
  background-color: #07c160;
  border-color: #07c160;
}

</style>